/*
#Copyright (c) 2013, Philippe Bordron <philippe.bordron@gmail.com>
#
# This file is part of SIPPER.
#
# DCC is free software: you can redistribute it and/or modify
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU LESSER GENERAL PUBLIC LICENSE for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# along with SIPPER.  If not, see <http://www.gnu.org/licenses/>
*/
package combi.wip.sipper.modeling.genomes;

import java.util.Collection;
import java.util.HashSet;

public class Gene<E> {

	protected String id;
	protected Collection<E> products;
	long begin;
	long end;

	public Gene (String id)
	{
		this.id = id;
		products = new HashSet<E>();
		begin = 0;
		end = 0;
	}
	
	public Gene(Gene<E> other)
	{
		this.id = other.id;
		this.products = new HashSet<E>(other.products);
		this.begin = other.begin;
		this.end = other.end;
	}
	
	public long getBegin()
	{
		return this.begin;
	}
	
	public long getEnd()
	{
		return this.end;
	}
	
	public void setBegin(long begin) {
		this.begin = begin;
	}

	public void setEnd(long end) {
		this.end = end;
	}

	public void addProduct(E prot)
	{
		this.products.add(prot);
	}
	
	public void removeProduct(E prot)
	{
		this.products.remove(prot);
	}
	
	public String getId() {
		return id;
	}
	

	public Collection<E> getProducts() {
		return this.products;
	}
	

	@Override
	public int hashCode() {
		int result = id.hashCode();
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Gene<?> other = (Gene<?>) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return this.getId().toString();
	}

}
